﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BaGiaDanhCuop
{
    public class Stick_Light
    {
        public Texture2D Light_Move_TT;
        public Texture2D Light_Fighting_Fail_TT;
        public Texture2D Light_Fighting_Strong_TT;
        public Texture2D Light_Fighting_Mid_TT;

        public Animation Light_Move_Animation;
        public Animation Light_Fighting_Fail_Animation;
        public Animation Light_Fighting_Strong_Animation;
        public Animation Light_Fighting_Mid_Animation;

        public Vector2 position;
        public int state;

        public Stick_Light(Texture2D move, Texture2D fail, Texture2D strong, Texture2D mid, float x, float y, int state)
        {
            position = new Vector2(x, y);
            //Texture2D
            this.Light_Move_TT = move;
            this.Light_Fighting_Fail_TT = fail;
            this.Light_Fighting_Strong_TT = strong;
            this.Light_Fighting_Mid_TT = mid;
            //Animation
            Light_Fighting_Fail_Animation = new Animation(position, Light_Fighting_Fail_TT, new Microsoft.Xna.Framework.Point(5, 2));
            Light_Fighting_Fail_Animation.animate(0.125f);
            Light_Fighting_Mid_Animation = new Animation(position, Light_Fighting_Mid_TT, new Microsoft.Xna.Framework.Point(6, 1));
            Light_Fighting_Mid_Animation.animate(0.125f);
            Light_Fighting_Strong_Animation = new Animation(position, Light_Fighting_Strong_TT, new Microsoft.Xna.Framework.Point(6, 1));
            Light_Fighting_Strong_Animation.animate(0.125f);
            Light_Move_Animation = new Animation(position, Light_Move_TT, new Microsoft.Xna.Framework.Point(5, 2));
            Light_Move_Animation.animate(0.125f);

            //attributes
            this.state = state;
        }

        public void UpdateState()
        {
            if (state == GamePage.STATE_STRONG && Light_Fighting_Strong_Animation.FrameIndex == 5)
            {
                Light_Fighting_Strong_Animation.PlayFromFrameIndex(0);
                state = GamePage.STATE_MOVE;
                GamePage.Power_Status = false;
                GamePage.PowerRectangle.Width = 0;
            }
            else if (state == GamePage.STATE_MID && Light_Fighting_Mid_Animation.FrameIndex == 5)
            {
                Light_Fighting_Mid_Animation.PlayFromFrameIndex(0);
                state = GamePage.STATE_MOVE;
                GamePage.Power_Status = false;
                GamePage.PowerRectangle.Width = 0;
            }
        }
    }
}
